package com.hktf.uilib.utils;

import android.content.Context;

import com.hktf.corelib.utils.CommUtils;
import com.hktf.corelib.utils.GsonUtils;
import com.hktf.corelib.utils.LogMds;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.tencent.mm.opensdk.modelpay.PayReq;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;


public class WxsdkUtil {
    public static final String APP_ID = "wx0472b3e4f9884d20";
    public static void gotoCJshanchen(Context context){
        String appId = "wx8577bf568c9593a3"; // 填移动应用(App)的 AppId，非小程序的 AppID
//        IWXAPI api = WXAPIFactory.createWXAPI(context, appId);
//
//        WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
//        req.userName = "gh_659c77edabac"; // 填小程序原始id
//        //            req.path = path;                  ////拉起小程序页面的可带参路径，不填默认拉起小程序首页，对于小游戏，可以只传入 query 部分，来实现传参效果，如：传入 "?foo=bar"。
//        req.miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE;// 可选打开 开发版，体验版和正式版
//        api.sendReq(req);
    }

    public static void gotoWxlogin() {
        IWXAPI api = WXAPIFactory.createWXAPI(CommUtils.getContext(), APP_ID);
        final SendAuth.Req req = new SendAuth.Req();
        req.scope = "snsapi_userinfo"; // 只能填 snsapi_userinfo
        req.state = "wechat_sdk_demo_test";
        api.sendReq(req);
    }

    public static void gotoWxPay(PayReq payReq) {
        IWXAPI api = WXAPIFactory.createWXAPI(CommUtils.getContext(), APP_ID, true);
//        final SendAuth.Req req = new SendAuth.Req();
//        req.scope = "snsapi_userinfo"; // 只能填 snsapi_userinfo
//        req.state = "wechat_sdk_demo_test";
        LogMds.e("cdz", "payReq:" + GsonUtils.createGsonString(payReq));
        api.sendReq(payReq);
    }
}
